﻿/*
    模块:         雷霆菜单生成器
    所属项目模块:  自由行单元测试
    作者:         顾金翼(Master HaKu)
    日期:         2012/07/24
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zeus.Thunder.Menu;

namespace Perseus.WCF.REST.Client
{
    public class MenuUtil
    {
        public static MainMenu GenMenu()
        {
            //基础知识
            SubMenu subMenuBasic = new SubMenu("基础知识", "Perseus.WCF.REST.Client.Basic");
            subMenuBasic.AddMenuItem(new MenuItem("Hello Test", "HelloTest"));
            subMenuBasic.AddMenuItem(new MenuItem("Get Employees Test", "GetEmployeeTest"));
            subMenuBasic.AddMenuItem(new MenuItem("Update Employees Test", "EmpUpdTest"));

            //主菜单
            MainMenu menu = new MainMenu();
            menu.AddSubMenu(subMenuBasic);

            return menu;
        }

        public static void Communicate()
        {
            MainMenu menu = MenuUtil.GenMenu();
            menu.Display();

            string mainIndex = Console.ReadLine();
            SubMenu subMenu = menu.ClickMenu(mainIndex);
            subMenu.Display();

            string subIndex = Console.ReadLine();
            MenuItem menuItem = subMenu.ClickMenu(subIndex);
            menuItem.Execute();
        }
    }
}
